﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CutAways.Geometry;

using Tao.OpenGl;

namespace CutAways.Illustration
{
	[Serializable]
	class AxesBoundingBox : BoundingBox
	{
		public Vector RotationAngles = new Vector(0f, 0f, 0f);

		private Vector min, max; // absolutni rohovy pozice obalky
		
		public Vector Min
		{
			get { return min; }
			set	{ min = value; }
		}
		
		public Vector Max
		{
			get { return max; }
			set { max = value; }
		}
		
		public override Vector Center
		{
			get { return Vector.CenterOfLink(min, max); }
		}

		public override float Radius
		{
			get { return (max - Center).GetLength(); }
		}

		public AxesBoundingBox(Vector min, Vector max)
		{
			this.min = min;
			this.max = max;
		}

		public override void Draw()
		{
			Gl.glDisable(Gl.GL_LIGHTING);
			Gl.glBegin(Gl.GL_LINES);
			{
				Gl.glVertex3f(min.X, min.Y, min.Z);
				Gl.glVertex3f(max.X, min.Y, min.Z);

				Gl.glVertex3f(min.X, min.Y, min.Z);
				Gl.glVertex3f(min.X, max.Y, min.Z);

				Gl.glVertex3f(min.X, min.Y, min.Z);
				Gl.glVertex3f(min.X, min.Y, max.Z);

				Gl.glVertex3f(min.X, max.Y, max.Z);
				Gl.glVertex3f(max.X, max.Y, max.Z);

				Gl.glVertex3f(min.X, max.Y, max.Z);
				Gl.glVertex3f(min.X, min.Y, max.Z);

				Gl.glVertex3f(min.X, max.Y, max.Z);
				Gl.glVertex3f(min.X, max.Y, min.Z);

				Gl.glVertex3f(max.X, min.Y, max.Z);
				Gl.glVertex3f(max.X, max.Y, max.Z);

				Gl.glVertex3f(max.X, min.Y, max.Z);
				Gl.glVertex3f(min.X, min.Y, max.Z);

				Gl.glVertex3f(max.X, min.Y, max.Z);
				Gl.glVertex3f(max.X, min.Y, min.Z);

				Gl.glVertex3f(max.X, max.Y, min.Z);
				Gl.glVertex3f(min.X, max.Y, min.Z);

				Gl.glVertex3f(max.X, max.Y, min.Z);
				Gl.glVertex3f(max.X, max.Y, max.Z);

				Gl.glVertex3f(max.X, max.Y, min.Z);
				Gl.glVertex3f(max.X, min.Y, min.Z);
			}
			Gl.glEnd();
			Gl.glEnable(Gl.GL_LIGHTING);

		}

	}
}
